package com.example.springsecurity.demo.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {

    @RequestMapping("login")
    public String login(){
        System.out.println("执行登录方法");
        return "redirect:main.html";
    }

    @Secured("ROLE_base")
    @PostMapping("/toMain")
    public String toMain(){
        System.out.println("toMain");
        return "redirect:main.html";
    }

    @PostMapping("/toError")
    public String toError(){
        System.out.println("toError");
        return "redirect:error.html";
    }

    @RequestMapping("demo")
    public String demo(){
        return "demo";
    }
}